package com.renjibo.teawithmilkgoods.adapters;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.renjibo.teawithmilkgoods.R;

import java.util.List;

/**
 * 任继波
 * Created by Administrator on 2017/2/15.
 */

public class MyRecycleAdapter extends RecyclerView.Adapter<MyRecycleAdapter.ViewHolder> {
    private List<String> list;

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.recycle_item,parent,false);
        ViewHolder holder=new ViewHolder(view);
        return holder;
    }
    public MyRecycleAdapter(List<String> list){
        this.list=list;
    }
    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        String name=list.get(position);
        holder.textView.setText(name);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView textView;
        public ViewHolder(View view){
            super(view);
            textView= (TextView) view.findViewById(R.id.textView);
        }
    }
}
